﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace QT.Text
{
    /// <summary>
    /// 字符串判断类
    /// </summary>
    public class Match
    {
        /// <summary>
        /// 判断字符串是否只包含正整数
        /// </summary>
        /// <param name="number">待检查的字符串</param>
        /// <returns>bool</returns>
        public static bool IsPos(string number)
        {
            if (Regex.IsMatch(number, @"^\d+$")&&(!Regex.IsMatch(number,@"^0+$")))
            {
                return true;
            }

            return false;
        }

        /// <summary>
        /// 判断字符串是否全部为数字
        /// </summary>
        /// <param name="number">待检查的字符串</param>
        /// <returns>bool</returns>
        public static bool IsNumeric(string number)
        {
            if(Regex.IsMatch(number,@"^[\d]+$"))
            {
                return true;
            }
            
            return false;
        }
    }
}
